package com.tiantianyuegou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tiantianyuegou.R;

/**
 * Created by Administrator on 2016/1/15.
 */
public class MyBankCardAdapter extends BaseAdapter implements View.OnClickListener{

    private Context context;
    private String[] text_bank_name;
    private String[] text_bank_name_num;
    private LayoutInflater inflater;

    public MyBankCardAdapter(){

    }

    public MyBankCardAdapter(Context context,String[] text_bank_name,String[] text_bank_name_num){
        this.context = context;
        this.text_bank_name=text_bank_name;
        this.text_bank_name_num=text_bank_name_num;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {

        return text_bank_name.length;
    }

    @Override
    public Object getItem(int i) {

        return i;
    }

    @Override
    public long getItemId(int i) {

        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        Holder holder=null;
        if (view==null){
            view=inflater.inflate(R.layout.item_list_bankcard,null);
            holder=new Holder();
            holder.text_bank_name=(TextView)view.findViewById(R.id.text_bank_name);
            holder.text_bank_name_num=(TextView)view.findViewById(R.id.text_bank_name_num);
            holder.img_delete=(ImageView)view.findViewById(R.id.img_delete);
            view.setTag(holder);
        }else{
            holder=(Holder)view.getTag();
        }
        holder.text_bank_name.setText(text_bank_name[i]);
        holder.text_bank_name_num.setText(text_bank_name_num[i]);
        holder.img_delete.setImageResource(R.mipmap.lajitong);
        holder.img_delete.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.img_delete:
                break;

            default:
                break;
        }
    }

    public static class Holder{
        TextView text_bank_name,text_bank_name_num;
        ImageView img_delete;
    }
}
